﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace pxt
{
    public class AnnouncementText
    {
        protected string mMessage;
        protected float mCurScale, mTargetScale;
        protected Vector2 mPosition;
        SpriteFont mFont;
        Color mColor;
        TongaTimer mTimer;

        // display options
        protected float mFadeInTime;
        protected float mFadeOutTime;
        protected float mDisplayTime;
        protected float mScaleTime;

        protected float mStartScale;

        protected bool mDisplay;

        public AnnouncementText()
        {
            mMessage = null;
            mTargetScale = 3.0f;
            mCurScale = 0.0f;
            mPosition = new Vector2(300, 350);
            mColor = Color.White;
            mDisplay = false;

            mDisplayTime = 2.0f;
            mFadeInTime = .5f;
            mFadeOutTime = .5f;

            mTimer = new TongaTimer(1.0);
        }

        public void Load()
        {
            //GameGlobals.Content.Load<SpriteFont>("announcefont");
        }

        public void Draw()
        {
            //sb.DrawString(mFont, mMessage, mPosition, Color.White, 0.0f, Vector2.Zero, mScale, SpriteEffects.None, 0);
            // TODO: Add scaled text to graphics system.
            GameSystems.Graphics.DrawScaledOrRotatedText(mMessage, mPosition, mCurScale, mColor);

            if (mCurScale >= mTargetScale)//mTimer.Check())
            {
                if (mTimer.Check())
                {
                    mDisplay = false;
                    mCurScale = 0.0f;
                    mTimer.Reset();
                }
            }
            else
            {
                mCurScale += mTargetScale * .09f;
                mTimer.Reset();
            }
        }

        public void Update(GameTime gt)
        {
            //update timer
            mTimer.Update(gt);
            // update our properties for whatever effect we want
        }

        public Color Color
        {
            get { return mColor; }
            set { mColor = value; }
        }

        public float TargetScale
        {
            get { return mTargetScale; }
            set { mTargetScale = value; }
        }

        public string Message
        {
            get { return mMessage; }
            set { mMessage = value; }
        }

        public Vector2 Position
        {
            get { return mPosition; }
            set { mPosition = value; }
        }

        public bool Display
        {
            get { return mDisplay; }
            set
            {
                if (value == true)
                {
                    mTimer.Reset();
                }
                mDisplay = value;
            }
        }


    }
}
